﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using DoeLibsMVC.Models;
using DoeObjects;
using System.Threading.Tasks;

namespace DoeLibsMVC.Controllers.api
{
    public class ProcessRowController : BaseApiController
    {
       [Security.BasicAuthorize(Roles = Security.UserCategoryHelper.STAFF_CATEGORY)]
        public async Task<HttpResponseMessage> Post([FromBody]string rowJSON)
        {
            JArray row = JsonConvert.DeserializeObject<JArray>(rowJSON);

            ImportReturn returnValues = await Import.processRow(row, User.UserId);

            return Request.CreateResponse(HttpStatusCode.OK, returnValues);
        }
    }
}